{% extends "counterpoint/forum_base.html" %}

{% block content %}
{% regroup object_list|dictsort:"parent_group.ordering" by parent_group as grouped %}
    <table>
{% for group in grouped %}
      <tr class="forumgroup_title">
        <th>&nbsp;</th>
        <th colspan="3">{{ group.grouper.title }}</th>
      </tr>
      <tr class="forumgroup_header">
        <th>&nbsp;</th>
        <th>Forum</th>
        <th>Topics</th>
        <th>Last Post</th>
      </tr>
  {% for forum in group.list|dictsort:"ordering" %}
      <tr class="{% cycle row1,row2 as rowcolors %}">
        <td class="forum_icon">
          {# <img title="{% unread_forum_status %}" src="{{ MEDIA_URL }}images/forum_{% unread_forum_status %}.gif" alt="" /> #}
        </td>
        <td>
          <span class="forum_name"><a href="{{ forum.get_absolute_url }}">{{ forum }}</a></span><br />
          <span class="forum_description">{{ forum.description }}</span>
        </td>
        <td class="forum_threads">
          {{ forum.thread_count }}
        </td>
    {% if forum.last_post.last_reply %}
      {% with forum.last_post.last_reply as last_reply %}
        <td class="last_post">
          <a href="{{ last_reply.get_absolute_url }}">{{ last_reply.title_escaped }}</a>
          by
          <a class="{{ last_reply.author.get_access_display }}" href="{{ last_reply.author.get_absolute_url }}">{{ last_reply.author }}</a>
          <br />
          {{ last_reply.posted|date:"F j, Y \a\t H:i" }}
        </td>
      {% endwith %}
    {% else %}
      {% if forum.last_post %}
        <td class="last_post">
          <a href="{{ forum.last_post.get_absolute_url }}">{{ forum.last_post.title_escaped }}</a>
          by
          <a class="{{ forum.last_post.author.get_access_display }}" href="{{ forum.last_post.author.get_absolute_url }}">{{ forum.last_post.author }}</a>
          <br />
          {{ forum.last_post.posted|date:"F j, Y \a\t H:i" }}
        </td>
      {% else %}
        <td class="last_post">&nbsp;</td>
      {% endif %}
    {% endif %}
      </tr>
  {% endfor %}
{% endfor %}
    </table>
{% endblock %}
